//
//  GHSMineViewController.m
//  penzer
//
//  Created by 还带大道 on 2018/11/14.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "GHSMineViewController.h"
#import "BZMineHearView.h"
#import "BZMainOrderDesTableViewCell.h"
#import "BZMineRegularItemTableViewCell.h"
#import "BZMineRegualTableModel.h"
#import "BZMangerFileViewController.h"
#import "BZGHSSetViewController.h"
#import "MyMoenyViewController.h"
#import "BZ_GHS_MessViewController.h"
#import "BZ_GHS_PermissionViewController.h"

@interface GHSMineViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property(nonatomic,copy)NSMutableArray *table_Data;
@end

@implementation GHSMineViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.navigationItem.title = @"我的";

    [self setupTableView];
    [self configData];
}


-(void)configData{
    NSArray *images = @[@"组 574",@"组 573",@"组 572",@"组 571",@"组 570",@"组 569"];
    NSArray *titles = @[@"我的押金",@"资料管理",@"证书管理",@"权限管理",@"客服服务",@"设置"];
    for(int i =0;i<images.count;i++){
        BZMineRegualTableModel*model = [BZMineRegualTableModel new];
        model.title = titles[i];
        if(i==0){
            model.sub_title = @"¥50,000";
            
        }
        model.titleColor = RGB(51, 51, 51);
        model.subtitleColor = RGB(51, 51, 51);
        model.canClick = 1;
        model.imageStr = images[i];
        [self.table_Data addObject:model];
    }
    [self.tableView reloadData];
}


-(void)setupTableView
{
     [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([BZMainOrderDesTableViewCell class]) bundle:nil]  forCellReuseIdentifier:NSStringFromClass([BZMainOrderDesTableViewCell class])];
     [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([BZMineRegularItemTableViewCell class]) bundle:nil]  forCellReuseIdentifier:NSStringFromClass([BZMineRegularItemTableViewCell class])];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.estimatedRowHeight = 200;
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
}


-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [BZMineHearView ShareHeadView];
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 80;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.table_Data.count+1;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row==0){
        BZMainOrderDesTableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:NSStringFromClass([BZMainOrderDesTableViewCell class])];
        return cell;
    }else{
        //BZMineRegularItemTableViewCell
        BZMineRegularItemTableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:NSStringFromClass([BZMineRegularItemTableViewCell class])];
        [cell setModel:self.table_Data[indexPath.row-1]];
        return cell;
    }
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row!=0){
        BZMineRegualTableModel *model = self.table_Data[indexPath.row-1];
        if(model.canClick==1){
            if(indexPath.row==1){
                MyMoenyViewController *vc = [[MyMoenyViewController alloc]init];
                [self.navigationController pushViewController:vc animated:NO];
            }else if (indexPath.row==2){
                BZMangerFileViewController *vc = [[BZMangerFileViewController alloc]init];
                [self.navigationController pushViewController:vc animated:NO];
            }else if (indexPath.row==6){
                BZGHSSetViewController *vc = [[BZGHSSetViewController alloc]init];
                 [self.navigationController pushViewController:vc animated:NO];
            }else if (indexPath.row==5){
                BZ_GHS_MessViewController *vc = [[BZ_GHS_MessViewController alloc]init];
                [self.navigationController pushViewController:vc animated:NO];
            }else if (indexPath.row==4){
                BZ_GHS_PermissionViewController *vc = [[BZ_GHS_PermissionViewController alloc]init];
                [self.navigationController pushViewController:vc animated:NO];
            }
        }
    }
}


#pragma mark--getter&&setter
-(NSMutableArray *)table_Data{
    if(!_table_Data){
        _table_Data=[NSMutableArray array];
    }
    return _table_Data;
}

@end
